<%@ page language="java" pageEncoding="UTF-8" buffer="16kb"%>
<%@ include file="/base.jsp"%>
<%@ include file="/module/taglibs.jsp"%>
<%@ include file="/module/nocache.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<%@ include file="/module/js.jsp"%>
<%@ include file="/module/orderField.jsp"%>

<style>

table label.error {
    margin-left: 5px;
    width: auto;
    display: inline;
    color: red;
}


</style>
</head>
<body>

 <div id="box" class="easyui-tabs" style="borde:none;">
    <div title="项目材料基本信息">
		  <!-- <table cellpadding="1" cellspacing="1" border="0">
						<tr>
							<td><input type="text" id="ButOK" class="inputButton" style="text-align: center;" value="选择班主任 " /></td>
						</tr>
					</table> -->
        <input type="hidden" name="id" id="id"  value="${data.xmid}"/>
		<table cellpadding="0" cellspacing="0" border="0" class="table-border" width="95%">
			<tr>
				<td class="table-header" colspan="4">材料项目信息</td>
			</tr>
			<tr>
				<td class="table-titleTD" style="width: 15%">材料项目名称:</td>
				<td class="table-contentTD"  style="width: 35%">${data.xmmc}</td>
		    </tr>
		    <tr>
		   	    <td class="table-titleTD" style="width: 15%">排序次序:</td>
				<td class="table-contentTD">${data.orders}</td>
			</tr>
			
			<tr>
				<td class="table-titleTD" style="width: 15%">项目状态:</td>
				<td class="table-contentTD">
			     	<c:if test="${data.states=='true'}">有效</c:if>
					<c:if test="${data.states=='false'}">无效</c:if>
				</td>
			</tr>
		    <tr>
				<td class="table-titleTD" style="width: 15%">提交期限:</td>
				<td class="table-contentTD">${data.deadline1}</td>
			</tr>
			
		     <tr>
				<td class="table-titleTD" style="width: 15%">发布状态:</td>
				<td class="table-contentTD">
					<c:if test="${data.issued=='true'}">已发布</c:if>
					<c:if test="${data.issued=='false'}">未发布</c:if>
				</td>
		    </tr>
		    <tr>		
				
				<td class="table-titleTD" style="width: 15%">发布时间:</td>
				<td class="table-contentTD">${data.issuetime1}</td>
			</tr>
			
			<tr>
				<td class="table-titleTD">备注:</td>
				<td class="table-contentTD" colspan="2">${data.remark}</td>
			</tr>
		</table>
		<br/>
		</br>
		<table cellpadding="1" cellspacing="1" border="0" align="left">
			<tr>
				<%-- <c:if test="${data.issued=='true'}">
			    <td><input type="text" id="ButOK" class="inputButton" style="text-align: center;" value="选择班主任 " /></td>
			    </c:if> --%>
			    <c:if test="${data.issued=='false'}">
			       <c:if test="${_login_user_type==2}">
			   <%--     <kl:permission permisstionList="${permisstionList}" currentUser="${_login_console_user}" currentCatalogId="<%=CatalogUtils.getCatalogId("XGGL_BJXX_BJCL")%>" key="modify">			 --%>
				  <td><input type="button" id="btnSave" class="inputButton" style="text-align: center;" value="修改" /></td>
			<%-- 	  </kl:permission> --%>
				</c:if>
				</c:if>
				<td><input type="button" id="returnBut"  class="inputButton" value="返回"  style="text-align: center;"/></td>
			 </tr>
			
		</table>
    </div>
    <div title="班主任设置范围"  data-options="closable:true">
		      <br />
		      <form action="#" name="Form" id="Form" method="post">
				 <input type="hidden" name="idList" id="idList"/>
				<table cellpadding="1" cellspacing="1" border="0">
					<tr>
					<c:if test="${issued=='false'}">
					   <kl:permission permisstionList="${permisstionList}" currentUser="${_login_console_user}" currentCatalogId="<%=CatalogUtils.getCatalogId("XGGL_BJXX_BJCL")%>" key="add">	
						<td><input type="button" id="btnAdd" 	value="指 定 为 全 部 班 主 任"
							class="inputButton" /></td>
						<td><input type="button"  onclick="javascript:addbzgr()" value="添 加 班 主 任"
							class="inputButton" /></td>
						</kl:permission>
						<kl:permission permisstionList="${permisstionList}" currentUser="${_login_console_user}" currentCatalogId="<%=CatalogUtils.getCatalogId("XGGL_BJXX_BJCL")%>" key="delete">				
						<td><input type="button" id="btnDelete"  value="删 除 班 主 任"
							 class="inputButton"/></td>
					     </kl:permission>
							 
				    </c:if>			 
					  <!--   <td><input type="button" id="btnBreak" value="返 回"
							 class="inputButton"/></td>	  -->
					</tr>
				</table>
				   <br />
		      <table id="dg" class="easyui-datagrid "  style="width:100%;" 
				data-options="pagination:false,collapsible:true,url:'${basePath}/bjxxClassMaterialRange/List?xmid='+${data.xmid},method:'post',remoteSort:true">
				<thead>
					<tr>
						<th data-options="field:'parentid',width:100,align:'left',hidden: true"></th>
						<th data-options="field:'empid',width:80,align:'left',hidden: true"></th>
						<th data-options="field:'bjid',width:80,align:'left',hidden: true"></th>
					    <th data-options="field:'rangeid',checkbox:true,width:80,align:'left'"></th>
					    <th data-options="field:'rownumbers',width:60,align:'left',formatter:formxl">序号</th>
						<th data-options="field:'zgh',sortable:true,nowrap:true,width:200,align:'left'">工号</th>
						<th data-options="field:'xm',nowrap:true,width:200,align:'left',sortable:true">姓名</th>
						<th data-options="field:'xb',nowrap:true,width:200,align:'left',sortable:true">性别</th>
						<th data-options="field:'bjmc',nowrap:true,width:200,align:'left',sortable:true">班级名称</th>
						<!-- <th data-options="field:'createtime',nowrap:true,width:200,align:'center',sortable:true">提交材料</th> -->
					</tr>
				</thead>
			 </table>	
			</form>	
				
		   <div id="show" style="display: none;">
					<table cellpadding="0" cellspacing="0" border="0"class="table-border">
					 <tr>
				  	 <td style="clear:both; width: 45%">
				  	   <input class="text" name="searchemp" ondblclick="javascript:filterSelectItems('sourseFromSelect2','fromSelect','fromSelect',this.value);"  onkeyup="javascript:filterSelectItems('sourseFromSelect2','fromSelect','fromSelect',this.value);"/><font color="green">在此查找</font> <br/>
				  	   <br/><label style="color:red;">未选择:</label><br/>
				  	   <select name="fromSelect" id="fromSelect" multiple="multiple" style="width:400px; height: 300px;">
							ondblclick="moveField('fromSelect','toSelect');">
										  <c:forEach items="${List}" var="data">
													     <%--   <option value="${data.emid}">${data.xm}</option> --%>
													      <option value="${data.bjid}">${data.xm}</option>
												          </c:forEach>
						</select>
						<select name="sourseFromSelect2" id="sourseFromSelect2" multiple="multiple" style="width: 220px; height: 150px; display: none;" >
						<option value="1">xxxx</option>
										  <c:forEach items="${List}" var="data">
													      <%-- <option value="${data.emid}">${data.xm}</option> --%>
													      <option value="${data.bjid}">${data.xm}</option>
												          </c:forEach>
				  	    </select>
				  	  </td>
				  	    <td align="center" style="width: 10%">
				  	    <input type="button"  onclick="moveAllField('fromSelect','toSelect');" style="width: 50px;" value=">>" /><br> <br/>
						<input type="button" onclick="moveField('fromSelect','toSelect');" style="width: 50px;" value=">" /><br/><br/>
						<input type="button"   style="width: 50px;" value="&lt" onclick="moveField('toSelect','fromSelect');"/><br/> <br/>
				     	<input type="button" style="width: 50px;" onclick="moveAllField('toSelect','fromSelect');"  value="&lt&lt" />
				     </td>
				     <td style="width: 45%"><br/><label style="color:red;">已经选中:</label><br/>
				     <select name="toSelect" id="toSelect" multiple="multiple"  class="text" selected="selected" style="width:400px;height: 300px;" ondblclick="moveField('toSelect','fromSelect');">
					 </select>
				    </td>	    
				  </tr>
				 </table>
	          </div>	
       
    </div>
   <!--  <div title="Tab3"
         data-options="iconCls:'icon-reload',closable:true">
        tab3
    </div> -->
</div> 
		 
	
		<script>
		
		    function formxl(value, row, index) {
	          return index;
	        } 
		
			$(document).ready(function() {
				 $("#btnSave").click(function() {
					 window.location.href ="${basePath}/bjxxClassMaterialProject/updateToview?id="+ $("#id").val();
		 		 });
				
			/* 	 $("#ButOK").click(function() {
					 window.location.href ="${basePath}/bjxxClassMaterialRange/index?xmid="+ $("#id").val();
		 		 }); */
				 
				 $("#returnBut").click(function() {
		 			 window.location.href='${basePath}/bjxxClassMaterialProject/index';
		 		 });
			});
		</script>
		
		
		
		<script type="text/javascript">
			$(document).ready(
							function() {
						
					         	$('#dg').datagrid({
								 onSortColumn :function(sort,order){
								   var _sort=sort;
								   var _order=order;
								   var options=$('#dg').datagrid('getPager').data("pagination").options;
								   var page=options.pageNumber;
								   var pageSize=options.pageSize;
								   window.setTimeout(function(){
									   $.post("${basePath}/bjxxClassMaterialRange/List",{orderFlag:_order,orderField:_sort},
												function(data){
												  $('#dg').datagrid("loadData",data); 
											   });
											   },100);  
								   },
								   rowStyler: function(index,row){
								   }
								});
								
					         	$('#btnBreak').click(function() {
									   window.location.href = "${basePath}/bjxxClassMaterialProject/details?id="+$('#id').val();
								});
					         	
					         	
					         	$('#btnAdd').click(function() {
					         		  layer.confirm("您是否确定指定为全部班主任数据信息", {icon: 3, title:'提示',skin:'layer-ext-moon'}, function(index){
					         			
					         			  $.ajax({
											    method : 'POST',
												url : '${basePath}/bjxxClassMaterialRange/add_bzr_all',
												data :{
													 xmid : $('#id').val()
												 },
											     traditional:true,//阻止深度序列化
												 success : function(result) {
													     if(result.statua=="100"){
													        layer.alert('添加班主任成功', {icon: 6});
													        location=location;
												         }else if(result.statua=="-99"){
												        	layer.alert('服务器异常', {icon: 5});
															return false;
													     }
												  }
										    }); 
									  },function(index){
											layer.close(index);
									  });
								});
					         	
					         	
					         	
					         	$('#btnDelete').click(function() {
						               $("#idList").val("");
										var count = 0;
										var idList = new Array();
									    var sels = $("#dg").datagrid("getSelections");
								    	for(var i in sels){
								    		idList.push(sels[i].bjid);
								    		count++;
								    	}
										if (count == 0) {
											layer.alert("您至少选择一条删除记录信息", {icon: 3});
											return false;
										}else{
											  layer.confirm("您是否删除当前选中数据信息", {icon: 3, title:'提示',skin:'layer-ext-moon'}, function(index){
												    $("#idList").val(idList);
												    document.Form.action = "${basePath}/bjxxClassMaterialRange/delete?xmid="+$('#id').val();
													document.Form.submit();
											  },function(index){
													layer.close(index);
											  });
										}
									});

					         	
							});
			
		</script>
		
		<script>
$(document).ready(
					function() {
						
						$("#show").dialog({
							width : 'auto',
							height : 'auto',
							bgiframe : true,
							modal : true,
							draggable : true,
							resizable : false,
							title : '添加班主任',
							autoOpen : false,
						    buttons : {
						    '取消' : function() {
						    	$(this).dialog('close');
							},
							'确定' : function() {
								    /*  if($("#toSelect").val()==null||$("#toSelect").val()==""){
										 alert("请选择一项");
										 return false;
									  } */
								  debugger;
								    var select = document.getElementById("toSelect");
								
								    var emidList=new Array();
								    for(i=0;i<select.length;i++){
								    	  emidList[i]=select[i].value;
								    }
									  if(emidList.length<1){
									     layer.alert("请选择一项", {icon: 3});
										 return false;
									  }
								  
								   $.ajax({
									    method : 'POST',
										url : '${basePath}/bjxxClassMaterialRange/add_bzr',
										data :{
											 emidList : emidList,
											 xmid : $('#id').val()
										 },
									     traditional:true,//阻止深度序列化
										 success : function(result) {
											     if(result.statua=="100"){
											        layer.alert('添加班主任成功', {icon: 6});
											        $(this).dialog('close');
											        location=location;
										         }else if(result.statua=="-99"){
										        	layer.alert('服务器异常', {icon: 5});
													return false;
											     }
										  }
								    }); 
							  
							}
						  }
						});

					});
	function addbzgr() {
		 $('#show').dialog('open');
	}
</script>		
</body>
</html>
